<template>
  <div class="play">
    <div class="play-kuan test-1">
      <div class="play-one">
        <div class="one-text">最近播放</div>
        <div class="one-button">
          <div class="button" @click="quanbu(play)">
            全部播放&nbsp;&nbsp;<van-icon name="plus" />
          </div>
        </div>
      </div>
      <div class="play-two"><Jie></Jie><Gequ :Gequ="play"></Gequ></div>
    </div>
  </div>
</template>

<script>
import Jie from "../components/Jie.vue";
import Gequ from "../components/Gequ.vue";
export default {
  name: "Play",
  components: {
    Jie,
    Gequ,
  },
  data() {
    return {
      value: "",
      activeIndex: 2,
      playshuzu: [],
      playshuju: "1939979974",
      play: [],
    };
  },
  created() {
    this.gai();
    this.transformation();
    this.request();
  },
  methods: {
    quanbu(e) {
      this.$store.state.zon = [];
      for (let i = 0; i < e.length; i++) {
        this.axios({
          method: "get",
          url: "/song/detail?ids=" + e[i].id,
        })
          .then((result) => {
            // console.log("result==>", result.data.songs);
            // this.like = result.data.songs;
            this.$store.commit("update", { data: result.data.songs[0] });
          })
          .catch((err) => {
            console.log("err==>", err);
          });
      }
      this.$store.commit("updateTwo", { data: e[0].id });
      this.axios({
        method: "get",
        url: "/song/url?id=" + e[0].id,
      })
        .then((result) => {
          // console.log("result==>", result.data.data[0].url);
          this.$store.commit("updateOne", { data: result.data.data[0].url });
          this.$store.commit("updateL", { data:  e[0].name});
          this.$store.commit("updateI", { data: e[0].al.picUrl });
        })
        .catch((err) => {
          console.log("err==>", err);
        });
      this.axios({
        method: "get",
        url: "/lyric?id=" + e[0].id,
      })
        .then((result) => {
          // console.log("result==>", result.data.lrc.lyric);
          this.$store.commit("updateLyric", { data: result.data.lrc.lyric });
        })
        .catch((err) => {
          console.log("err==>", err);
        });
    },
    gai() {
      setInterval(() => {
        this.$store.state.activeIndex = this.activeIndex;
        this.playshuzu = this.$store.state.play;
        // console.log("this.playshuzu==>", this.playshuzu);
      }, 100);
    },
    transformation() {
      this.playshuzu.forEach((e, i) => {
        this.playshuju += "," + e;
      });
      // console.log("this.playshuju==>", this.playshuju);
    },
    request() {
      this.axios({
        method: "get",
        url: "/song/detail?ids=" + this.playshuju,
      })
        .then((result) => {
          // console.log("result==>", result.data.songs);
          this.play = result.data.songs;
        })
        .catch((err) => {
          console.log("err==>", err);
        });
    },
  },
};
</script>

<style lang="less" scoped>
.play-three {
  width: 712.5px;
  height: 500px;
  font-size: 18px;
  color: #b3b3b3;
  line-height: 500px;
  text-align: center;
  background-color: white;
}
.test-1::-webkit-scrollbar {
  /*滚动条整体样式*/
  width: 5px; /*高宽分别对应横竖滚动条的尺寸*/
  height: 1px;
}
.test-1::-webkit-scrollbar-thumb {
  /*滚动条里面小方块*/
  // border-radius: 10px;
  box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
  background: #b3b3b3;
}
.test-1::-webkit-scrollbar-track {
  /*滚动条里面轨道*/
  box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
  // border-radius: 10px;
  background: #ededed;
}
.play-kuan {
  width: 712.5px;
  height: 500px;
  background-color: rgb(255, 255, 255);
  overflow-y: scroll;
  .play-one {
    width: 100%;
    height: 60px;
    font-size: 14px;
    .one-text {
      float: left;
      width: calc(50% - 20px);
      height: 60px;
      line-height: 60px;
      padding-left: 20px;
    }
    .one-button {
      float: right;
      width: calc(50% - 20px);
      height: 60px;
      padding-right: 20px;
      position: relative;
      .button {
        line-height: 32px;
        text-align: center;
        width: 120px;
        height: 32px;
        color: white;
        border-radius: 16px;
        position: absolute;
        right: 20px;
        top: 14px;
        background-color: rgb(252, 63, 63);
      }
    }
  }
}
</style>